Carbon


MPEnterCriticalRegion

Header: Multiprocessing.h Carbon status: Supported

Attempts to enter a critical region.

OSStatus MPEnterCriticalRegion (
    MPCriticalRegionID criticalRegion, 
    Duration timeout
);
criticalRegion

The ID of the critical region you want to enter.

timeout

The maximum time to wait for entry before timing out. See “Timer Duration Constants” for a list of constants you can use to specify the wait interval.

function result

A result code.

DISCUSSION

If another task currently occupies the critical region, the current task is blocked until the critical region is released or until the designated timeout expires. Otherwise the task enters the critical region and MPEnterCriticalRegion increments the region’s use count.

Once a task enters a critical region it can make further calls to MPEnterCriticalRegion without blocking (its use count increments for each call). However, each call to MPEnterCriticalRegion must be balanced by a call to MPExitCriticalRegion; otherwise the region is not released for use by other tasks.

Note that you can enter a critical region from a cooperative task. Each cooperative task is treated as unique and different from any preemptive task. If you call this function from a cooperative task, you should specify only kDurationImmediate for the timeout length; other waits will cause the task to block.

VERSION NOTES

Introduced with Multiprocessing Services 1.0.

AVAILABILITY

Supported in Carbon. Available in CarbonLib 1.0 and later when MPLibrary 1.0 or later is installed. Exported by CarbonLib 1.0 and later and by MPLibrary 1.0 and later.


© 2000 Apple Computer, Inc. — (Last Updated 4/6/2000)